import 'package:guochaoapp/model/payment_entity.dart';

paymentEntityFromJson(PaymentEntity data, Map<String, dynamic> json) {
	if (json['success'] != null) {
		data.success = json['success'];
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = new PaymentData().fromJson(json['data']);
	}
	if (json['sign'] != null) {
		data.sign = json['sign'];
	}
	return data;
}

Map<String, dynamic> paymentEntityToJson(PaymentEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['success'] = entity.success;
	data['msg'] = entity.msg;
	data['code'] = entity.code;
	if (entity.data != null) {
		data['data'] = entity.data.toJson();
	}
	data['sign'] = entity.sign;
	return data;
}

paymentDataFromJson(PaymentData data, Map<String, dynamic> json) {
	if (json['paymentNo'] != null) {
		data.paymentNo = json['paymentNo'].toString();
	}
	if (json['aliPayParams'] != null) {
		data.aliPayParams = json['aliPayParams'].toString();
	}
	if (json['wxPayParams'] != null) {
		data.wxPayParams = json['wxPayParams'];
	}
	if (json['receiptCard'] != null) {
		data.receiptCard = json['receiptCard'];
	}
	if (json['creditPaySuccess'] != null) {
		data.creditPaySuccess = json['creditPaySuccess'];
	}
	if (json['skipPaySuccess'] != null) {
		data.skipPaySuccess = json['skipPaySuccess'];
	}
	return data;
}

Map<String, dynamic> paymentDataToJson(PaymentData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['paymentNo'] = entity.paymentNo;
	data['aliPayParams'] = entity.aliPayParams;
	data['wxPayParams'] = entity.wxPayParams;
	data['receiptCard'] = entity.receiptCard;
	data['creditPaySuccess'] = entity.creditPaySuccess;
	data['skipPaySuccess'] = entity.skipPaySuccess;
	return data;
}